unit Test;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TfrmTest = class(TForm)
    CompatMode_CmbBox: TComboBox;
    Use256Color_ChkBox: TCheckBox;
    Use640x480_ChkBox: TCheckBox;
    DisableThemes_ChkBox: TCheckBox;
    DisableDWM_ChkBox: TCheckBox;
    HighDPIAware_ChkBox: TCheckBox;
    Apply_Btn: TButton;
    RunAsAdmin_ChkBox: TCheckBox;
    procedure Apply_BtnClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmTest: TfrmTest;

implementation

uses WinACI;

{$R *.dfm}

procedure TfrmTest.Apply_BtnClick(Sender: TObject);
  var
    WinACI : TWinACIObject;
begin
  WinACI := TWinACIObject.Create();
  Try
    With WinACI do
    begin
      Case CompatMode_CmbBox.ItemIndex of
        0: Mode := cmNone;
        1: Mode := cmWin95;
        2: Mode := cmWin98;
        3: Mode := cmNT4SP5;
        4: Mode := cmWin2000;
        5: Mode := cmWinXPSP2;
        6: Mode := cmWinXPSP3;
        7: Mode := cmWinSrv03SP1;
        8: Mode := cmWinSrv08SP1;
        9: Mode := cmVistaRTM;
       10: Mode := cmVistaSP1;
       11: Mode := cmVistaSP2;
      End;

      If Use256Color_ChkBox.Checked
      Then Settings := Settings + [cs256Color]
      Else Settings := Settings - [cs256Color];
      If Use640x480_ChkBox.Checked
      Then Settings := Settings + [cs640x480]
      Else Settings := Settings - [cs640x480];
      If DisableThemes_ChkBox.Checked
      Then Settings := Settings + [csDisableThemes]
      Else Settings := Settings - [csDisableThemes];
      If DisableDWM_ChkBox.Checked
      Then Settings := Settings + [csDisableDWM]
      Else Settings := Settings - [csDisableDWM];
      If HighDPIAware_ChkBox.Checked
      Then Settings := Settings + [csHighDPIAware]
      Else Settings := Settings - [csHighDPIAware];

      If RunAsAdmin_ChkBox.Checked
      Then PrivilegeLevel := plRunAsAdmin
      Else PrivilegeLevel := plDefault;

      ShowMessage(BoolToStr(SaveToRegistry, True));
    end;
  Finally
    FreeAndNil(WinACI);
  End;
end;

procedure TfrmTest.FormShow(Sender: TObject);
  var
    WinACI : TWinACIObject;
begin
  WinACI := TWinACIObject.Create();
  Try
    With WinACI do
    begin

      Case Mode of
        cmNone:        CompatMode_CmbBox.ItemIndex := 0;
        cmWin95:       CompatMode_CmbBox.ItemIndex := 1;
        cmWin98:       CompatMode_CmbBox.ItemIndex := 2;
        cmNT4SP5:      CompatMode_CmbBox.ItemIndex := 3;
        cmWin2000:     CompatMode_CmbBox.ItemIndex := 4;
        cmWinXPSP2:    CompatMode_CmbBox.ItemIndex := 5;
        cmWinXPSP3:    CompatMode_CmbBox.ItemIndex := 6;
        cmWinSrv03SP1: CompatMode_CmbBox.ItemIndex := 7;
        cmWinSrv08SP1: CompatMode_CmbBox.ItemIndex := 8;
        cmVistaRTM:    CompatMode_CmbBox.ItemIndex := 9;
        cmVistaSP1:    CompatMode_CmbBox.ItemIndex := 10;
        cmVistaSP2:    CompatMode_CmbBox.ItemIndex := 11;
      End;

      // Settings:
      Use256Color_ChkBox.Checked   := (cs256Color      in Settings);
      Use640x480_ChkBox.Checked    := (cs640x480       in Settings);
      DisableThemes_ChkBox.Checked := (csDisableThemes in Settings);
      DisableDWM_ChkBox.Checked    := (csDisableDWM    in Settings);
      HighDPIAware_ChkBox.Checked  := (csHighDPIAware  in Settings);

      // Privilege level:
      If (PrivilegeLevel = plRunAsAdmin) Then RunAsAdmin_ChkBox.Checked := True
                                         Else RunAsAdmin_ChkBox.Checked := False;
    end;
  Finally
    FreeAndNil(WinACI);
  End;
end;

end.
